/**   
 * Copyright © 2016 北京之洲科技有限责任公司. All rights reserved.
 * 
 * @Title: NewsDaoOfAutoHome.java 
 * @Prject: carfactory
 * @Package: com.zizo.autohome.news.post.dao 
 * @Description: 
 * @author: Alexis  
 * @email heyan0227@outlook.com
 * @date: 2016年8月15日 上午11:01:42 
 * @version: V1.0   
 */
package com.zizo.autohome.news.reply.dao;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import com.zizo.autohome.news.reply.bean.AutoHomeNewsReply;
import com.zizo.core.DAO;
import com.zizo.core.T;
import com.zizo.util.Util;

/**
 * @ClassName: NewsDaoOfAutoHome
 * @Description:
 * @author: Alexis
 * @date: 2016年8月15日 上午11:01:42
 */
public class NewsReplyDaoOfAutoHome extends DAO {

	/**
	 * @Title:NewsDaoOfAutoHome
	 * @Description:
	 * @param currConn
	 * @param coreConn
	 */
	public NewsReplyDaoOfAutoHome(Connection currConn, Connection coreConn) {
		super(currConn);
	}

	public List<String> getFinIDs() {
		Statement st = null;
		ResultSet rs = null;
		List<String> list = new ArrayList<>();
		String sql = "SELECT id FROM qczj_newsreply_fin";
		try {
			st = currConn.createStatement();
			rs = st.executeQuery(sql);
			while (rs.next()) {
				list.add(rs.getInt("id") + "");
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	public void insertNewsReply(AutoHomeNewsReply reply) {
		PreparedStatement ps = null;
		String sql = "REPLACE INTO ProjectTemp.other_news_reply_meng(reply_id,reply_kbid,reply_ptime,reply_content,reply_bhftzid,reply_uid,reply_hfyhmc,reply_floor,reply_sex,reply_length,reply_source,reply_uptime) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
		try {
			ps = currConn.prepareStatement(sql);
			ps.setInt(1, reply.getReplyId());
			ps.setInt(2, reply.getrObjId());
			Long time = new Long(reply.getrReplyDate());
			Date date = new Date(time);
			ps.setDate(3, date);
			ps.setString(4, reply.getrContent());
			ps.setInt(5, reply.getrTargetReplyId());
			ps.setInt(6, reply.getrMemberId());
			ps.setString(7, reply.getrMemberName());
			ps.setInt(8, reply.getrFloor());
			ps.setInt(9, reply.getrMemberSex());
			ps.setInt(10, reply.getrContentLength());
			ps.setString(11, reply.getSpType());
			ps.setTimestamp(12, (Timestamp) Util.getTimeHMS(Util.getCurrentDateTime()));
			ps.executeUpdate();
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	/*
	 * (non Javadoc)
	 * 
	 * @Title: getIDs
	 * 
	 * @Description:
	 * 
	 * @return
	 * 
	 * @see com.zizo.core.DAOInterface#getIDs()
	 */
	@Override
	public List<String> getIDs() {
		return null;
	}

	/*
	 * (non Javadoc)
	 * 
	 * @Title: insertData
	 * 
	 * @Description:
	 * 
	 * @param t
	 * 
	 * @return
	 * 
	 * @see com.zizo.core.DAOInterface#insertData(com.zizo.core.T)
	 */
	@Override
	public int insertData(T t) {
		return 0;
	}

	/*
	 * (non Javadoc)
	 * 
	 * @Title: updateTime
	 * 
	 * @Description:
	 * 
	 * @param type
	 * 
	 * @param id
	 * 
	 * @see com.zizo.core.DAOInterface#updateTime(java.lang.String,
	 * java.lang.String)
	 */
	@Override
	public void updateTime(String type, String id) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non Javadoc)
	 * 
	 * @Title: getTables
	 * 
	 * @Description:
	 * 
	 * @return
	 * 
	 * @see com.zizo.core.DAOInterface#getTables()
	 */
	@Override
	public List<String> getTables() {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non Javadoc)
	 * 
	 * @Title: insertError
	 * 
	 * @Description:
	 * 
	 * @param t
	 * 
	 * @return
	 * 
	 * @see com.zizo.core.DAOInterface#insertError(com.zizo.core.T)
	 */
	@Override
	public int insertError(T t) {
		// TODO Auto-generated method stub
		return 0;
	}

}
